package cn.thoughtworks.school.programCenter.feign;

import cn.thoughtworks.school.programCenter.entities.Organization;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;


@FeignClient(name="${feign.organizationCenter.name}",
        url = "${feign.organizationCenter.url}")
@Service
public interface OrganizationCenterFeign {

    @GetMapping("api/organizations/users/{userId}")
    List<Organization> getOrganizationsByUserId(@PathVariable("userId") Long userId);

    @PostMapping("api/organizations/{organizationId}/users")
    void addUsersToOrganization(@PathVariable("organizationId") Long organizationId, @RequestBody List<Long> userIds);

    @PostMapping("api/userOrganizations")
    void addUserOrganization(@RequestBody Map userOrganization);
}
